home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / modula2 / mod2src.arc / ARRAYS2.MOD < prev    next >
Text File  |  1987-02-08  |  1KB  |  41 lines

  1.                                          (* Chapter 6 - Program 2 *)
  2. MODULE Arrays2;
  3.  
  4. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  5.  
  6. VAR  Index, Count     : CARDINAL;
  7.      Checkerboard     : ARRAY[1..8] OF ARRAY[1..8] OF CARDINAL;
  8.      Value            : ARRAY[1..8],[1..8] OF CARDINAL;
  9.  
  10. BEGIN
  11.    FOR Index := 1 TO 8 DO
  12.       FOR Count := 1 TO 8 DO
  13.          Checkerboard[Index,Count] := Index + 3*Count;
  14.          Value[Index,Count] := Index + 2*Checkerboard[Index,Count];
  15.       END;  (* of Count loop *)
  16.    END;     (* of Index loop *)
  17.  
  18.    WriteString("Output of checkerboard");
  19.    WriteLn;
  20.    FOR Index := 1 TO 8 DO
  21.       FOR Count := 1 TO 8 DO
  22.          WriteInt(Checkerboard[Index,Count],6);
  23.       END;  (* of Count loop *)
  24.       WriteLn;
  25.    END;     (* of Index loop *)
  26.  
  27.    Value[3,5] := 77;   (* change a few of the values *)
  28.    Value[3,6] := 3;
  29.    Value[Value[3,6],7] := 2;  (* same as Value[3,7] := 2; *)
  30.  
  31.    WriteLn;
  32.    WriteString("Output of Value matrix");
  33.    WriteLn;
  34.    FOR Count := 1 TO 8 DO
  35.       FOR Index := 1 TO 8 DO
  36.          WriteInt(Value[Count,Index],6);
  37.       END;   (* of Index loop *)
  38.       WriteLn;
  39.    END;      (* of Count loop *)
  40. END Arrays2.
  41.